import {useState,useEffect} from 'react'
function useScrollPosition(){
    const [scrollY,setScrollY]=useState(0)
    const handleScroll=()=>{
        setScrollY(window.scrollY)
    }
    useEffect(()=>{
        document.addEventListener('scroll',handleScroll)
        return ()=>{
            document.removeEventListener(handleScroll)
        }
    },[])
    return scrollY
}   
export default useScrollPosition